const wxRequest = async(params = {}, url) => {
	console.log(url)
	if(url=='https://app.xpandago.net/app/goods/goodsDetail/share/saveOrderDeatail'){
		uni.showLoading({
			title: '图片生成中...',
			mask: true,
			icon:'none'
		});
	}else{
		uni.showLoading({
			title: '加载中...',
			mask: true,
			icon:'none'
		});
	}
	
    let data = params.query || {};
	let header = params.header || {'Content-Type': 'application/json'};
    let res = await uni.request({
        url: params.url || url,
        method: params.method || 'GET',
        data: data,
        header: header,
    });
    uni.hideLoading();
	 if(res!=null && res.data!=null && res.data.code==200){
		 uni.showToast({
		  	title: res.data.msg,
		  	icon: 'none'
		  })
		 uni.removeStorageSync('token');
		 setTimeout(() => {
			uni.reLaunch({
			  url: "/pages/login/login"
			})
		 }, 1000);
	 return res
	}else if(res!=null && res.data!=null && res.data.code==100){
		uni.showToast({
		 	title: res.data.msg,
		 	icon: 'none'
		 })
		uni.removeStorageSync('token');
		setTimeout(() => {
		uni.reLaunch({
			  url: "/pages/login/login"
			})
		}, 1000);
	return res
	}else{
	  return res;
	}
};
module.exports = {
    wxRequest
}
